"Student Number","Date Created","Assessment Title","Total Marks"
<?php 
foreach ($asessions as $asession)
{
	echo '"'.$asession['Asession']['student_number'].'",'.'"'.$asession['Asession']['created'].'",'.'"'.$asession['Assessment']['name'].'",';
	$total_marks = 0;

	foreach ($asession['Asessionlog'] as $result)
	{
		if (($result['question_id'] == 0) && ($result['answer'] > 0))
		{
			if ($result['correct'] == 1)
			{
				$total_marks += @$result['AnswerGiven']['Question']['marks_awarded'];
			}
		}
	}

	echo '"'.$total_marks.'"'."\n";
}
?>